#include<stdio.h>
#include"game.h"

void menu()
{
    printf("######################\n");
    printf("######################\n");
    printf("####---1.play---######\n");
    printf("####---0.exit---######\n");
    printf("######################\n");
    printf("######################\n");
    printf("请输入(1 or 0)\n");
}


void game()
{
    int ret=0;
    printf("玩家先下\n");
    char board[ROW][COL]={0};//初始化    
    csboard(board,ROW,COL);//为了初始化定义的函数
    pboard(board,ROW,COL);//为了打印棋盘定义的函数
    while(1)
    {
        
        playermove(board,ROW,COL);
        //判断输赢
          pboard(board,ROW,COL);
        ret=iswin(board,ROW,COL);
         if(ret!='c')
          break;

        computermove(board,ROW,COL);
          pboard(board,ROW,COL);
        //判断输赢
         ret=iswin(board,ROW,COL);
         if(ret!='c')
            break;
    }
     if(ret=='*') 
          printf("玩家获胜\n");
     else if(ret=='#')
        printf("电脑获胜\n");
     else if(ret=='Q')
        printf("平局\n");

        
}

int main()
{
    int input=0;
    do
    {
       menu();
       scanf("%d",&input);
       switch(input)
         {
            case 1:
              printf("开始游戏");
              game();
              break;
            case 0:
              printf("退出游戏");
              break;
            default:
              printf("请重新输入");
              break;
         }
    } while(input);
    
}